import java.io.File;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

import org.apache.commons.lang.StringUtils;


public class ReplaceFileName {
	
	JFrame frame = null;
	
	public ReplaceFileName(){
		frame = new JFrame();
		frame.setTitle("替换文件名");   
		frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);   
		frame.setVisible(true);   
		frame.setSize(805, 410);   
		frame.setResizable(false);   
		frame.setLocationRelativeTo(frame.getOwner());  

	}
	

	public static void main(String[] args) {
//		ReplaceFileName  r = new ReplaceFileName();
		File srcDir = new File("F:\\书集\\J2me\\qear3\\sdee\\");
		String namePrefix = "20140314";
		Integer start =100;
		StringBuffer name = new StringBuffer();
		File [] files = srcDir.listFiles();
		for(File f : files){
			name.setLength(0);
			if(f.isFile() && f.getName().endsWith("jpg")){
				name.append(namePrefix);
				name.append(StringUtils.leftPad(start.toString(), 4, '0'));
				name.append(".jpg");
				f.renameTo(new File(srcDir.getAbsolutePath()+"\\"+name));
				start ++;
			}
		}
		
	}

}
